package com.origin.src;

import com.origin.src.mybatis.XMyBatis;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.*;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@EnableTransactionManagement
@Configuration(proxyBeanMethods = true)
//@Component
@ComponentScan(value = "com.origin.*",excludeFilters = {@ComponentScan.Filter(value = SpringBootApplication.class)})
@EnableAspectJAutoProxy(exposeProxy = true)
@PropertySource("/application.properties")
@Import(XMyBatis.class)
@ImportResource("classpath:/spring.xml")
//@EnableLoadTimeWeaving(aspectjWeaving = EnableLoadTimeWeaving.AspectJWeaving.ENABLED)
public class XConfiguration extends XConfigurationFather implements Ordered {

    @Bean
//    @Primary
//    @Override
    public XBeanB XBeanB() {
        return new XBeanB("son");
    }
//
//    @Bean
////    @Bean(name = "XBeanB1")
//    public XBeanB XBeanB(BeanFactory beanFactory) {
//        return new XBeanB("son bean1");
//    }
//
//    @Bean
////    @Bean(name = "XBeanB1")
//    public XBeanB XBeanB(BeanFactory beanFactory,XConfiguration x) {
//        return new XBeanB("son bean2");
//    }

    @Override
    public int getOrder() {
        return 0;
    }


    public static class XBeanB {
        String a;

        public  XBeanB() {
        }

        public XBeanB(String a) {
            this.a = a;
        }

        @Override
        public String toString() {
            return super.toString()+"{" +
                    "a='" + a + '\'' +
                    '}';
        }
    }
}
